package com.team.book.web;

import com.team.book.common.constant.BookStatistics;
import com.team.book.common.constant.ResponseStatus;
import com.team.book.common.domain.Page;
import com.team.book.common.domain.ResponseEntity;
import com.team.book.common.exception.UncheckedException;
import com.team.book.domain.Book;
import com.team.book.domain.BookClassification;
import com.team.book.service.BookService;
import com.team.book.web.dto.BookDTO;
import com.team.book.web.dto.BookStatisticsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 图书
 * @author Joann
 *
 */
@RestController
@RequestMapping(value = "/api/book/statistics")
public class BookStatisticsController {

	@Autowired
	public BookService bookService;

    @GetMapping(value = "/borrow")
    public ResponseEntity<Page<BookStatisticsDTO>> borrow(Page<BookStatisticsDTO> page){
        Page<BookStatisticsDTO> bookPage = bookService.queryBorrowStatistics(page);
        return ResponseEntity.ok(bookPage);
    }

    @GetMapping(value = "/classification")
    public ResponseEntity<Page<BookStatisticsDTO>> classification(Page<BookStatisticsDTO> page){
        Page<BookStatisticsDTO> bookPage = bookService.queryClassificationStatistics(page);
        return ResponseEntity.ok(bookPage);
    }

}
